<!DOCTYPE html>
<html lang="zh"
      xmlns:th="http://www.thymeleaf.org">
<head th:replace="common/fragment::top">

</head>

<body>
<div class="lyear-layout-web">
  <div class="lyear-layout-container">
    <!--左侧导航-->
    <div th:replace="common/fragment::leftmenu"></div>
    <!--End 左侧导航-->

    <!--头部信息-->
    <div th:replace="common/fragment::header"></div>
    <!--End 头部信息-->

    <!--页面主要内容-->
    <main class="lyear-layout-content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-lg-12">
            <div class="card">
              <div class="card-body">
                <form
                    action="#!"
                    class="row"
                    id="icon-form"
                    method="post">
                  <!--                      菜单id-->
                  <input
                      hidden="hidden"
                      id="dbid"
                      name="dbid"
                      th:value="${dbPO.id}"
                      type="text"/>


                  <!--备份名词-->
                  <div class="input-group m-b-10">
                    <label
                        class="input-group-addon "
                        for="backname">备份名称
                    </label>
                    <input
                        class="form-control required"
                        id="backname"
                        name="backname"
                        readonly="readonly"
                        th:value="${dbPO.filename}"
                        type="text"/>
                  </div>
                  <!--备份日期-->
                  <div class="input-group m-b-10">
                    <label
                        class="input-group-addon "
                        for="createTime">备份日期
                    </label>
                    <input
                        class="form-control"
                        id="createTime"
                        name="createTime"
                        readonly="readonly"
                        th:value="${#dates.format(dbPO.createTime,'yyyy-MM-dd HH:mm:ss')}"
                        type="text"/>
                  </div>


                  <!--图标-->
                  <div class="input-group m-b-10">
                    <label
                        class="input-group-addon "
                        for="comment">备份注释
                    </label>
                    <input
                        class="form-control input-group-addon"
                        id="comment"
                        name="comment"
                        placeholder="-----备注------"
                        th:value="${dbPO.comment}"
                        type="text"/>

                  </div>


                  <div class="form-group col-md-12">
                    <button
                        class="btn btn-primary ajax-post"
                        id="save-db-btn"
                        target-form="add-form"
                        type="button">确 定
                    </button>
                    <button
                        class="btn btn-w-md btn-round btn-danger"
                        id="restore-db"
                        type="button">恢复备份
                    </button>
                    <button
                        class="btn btn-default"
                        onclick="history.back(-1);return false;"
                        type="button">取消
                    </button>
                  </div>
                </form>

              </div>
            </div>
          </div>

        </div>

      </div>

    </main>
    <!--End 页面主要内容-->
  </div>
</div>

<div th:insert="common/fragment::tail-script"></div>
<style>
  td > i {
    height: 24px;
    line-height: 24px;
    text-align: center;
    vertical-align: middle;
    font-size: 24px;
  }

  td:hover {
    background: #cccccc;
    border: red 2px solid;
  }

  #display-select-icon {
    height: 24px;
    line-height: 24px;
    text-align: center;
    vertical-align: middle;
    font-size: 24px;
  }

  .selected-icon {
    border: blue 2px solid;
  }

</style>

<!--    图标模态框-->
<div th:replace="common/iconfragment::iconmodal"></div>
<!--    END --图标模态框-->
<script type="text/javascript">
  $(document).ready(function () {

    // 添加注释
    $('#save-db-btn').click(function () {
      let id = $('#dbid').val()
      let comment = $('#comment').val()
      let data = {
        id: id,
        comment: comment
      }
      $.confirm({
        title: '修改备注？',
        content: '确定修改备注？',
        type: 'green',
        typeAnimated: false,
        buttons: {
          confirm: {
            text: '确认',
            action: function () {
              post_ajax('/database/editdb.ajax', data, '/database/dblist.do')
            }
          },
          cancel: {
            text: '取消',
            action: function () {

            }
          }
        }
      });
    })

    // 备份恢复
    $('#restore-db').click(function () {
      let id = $('#dbid').val()
      let data = {
        id: id,
      }
      $.confirm({
        title: '恢复备份？',
        content: '确定恢复备份？',
        type: 'orange',
        typeAnimated: false,
        buttons: {
          confirm: {
            text: '确认',
            action: function () {
              post_ajax('/database/restoredb.ajax', data, '/database/dblist.do')
            }
          },
          cancel: {
            text: '取消',
            action: function () {

            }
          }
        }
      });
    })

  });
</script>
</body>
</html>